<?php

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

class CreateDaili extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('daili', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('name');
        });
        
        Schema::table('admin', function (Blueprint $table) {
            $table->integer('daili_id')->after('id')->index();
        });
        
        Schema::table('products', function (Blueprint $table) {
            $table->integer('daili_id')->after('id')->index();
        });
        
        Schema::table('orders', function (Blueprint $table) {
            $table->integer('daili_id')->after('id')->index();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('daili');
        
        Schema::table('admin', function (Blueprint $table) {
            $table->dropColumn('daili_id');
        });
        
        Schema::table('products', function (Blueprint $table) {
            $table->dropColumn('daili_id');
        });
        
        Schema::table('orders', function (Blueprint $table) {
            $table->dropColumn('daili_id');
        });
    }
}
